package io.nmn.examples.freemarker;

import static spark.Spark.get;

import java.util.HashMap;
import java.util.Map;

import spark.ModelAndView;
import spark.template.freemarker.FreeMarkerEngine;




public class FreemarkerTemplate {

	public static void main(String args[]) {
		
		get("/freemarkerTemplate", (request, response) -> {
            Map<String, Object> attributes = new HashMap<>();
            attributes.put("message", "Hello World!");

            // The hello.ftl file is located in directory:
            // src/test/resources/spark/template/freemarker
            return new ModelAndView(attributes, "/examples/freemarkerTemplate.ftl");
        }, new FreeMarkerEngine());
		
		get("/layoutTemplate", (request, response) -> {
			Map<String, Object> viewObjects = new HashMap<String, Object>();
			
			viewObjects.put("message", "Hello World!");

            viewObjects.put("templateName", "/examples/freemarkerTemplate.ftl");

            return new ModelAndView(viewObjects, "/examples/layoutTemplate.ftl");
        }, new FreeMarkerEngine());


	}

}
